@import '../color.scss';
$count: 8;

.zhui-switch {
  position: relative;
  width: 60px;
  height: 60px;
  cursor: pointer;
  transform: rotate(90deg);
  transform-origin: center;

  &-text {
    z-index: 1;
    position: absolute;
    width: 40px;
    height: 15px;
    line-height: 15px;
    overflow: hidden;
    top: 40%;
    left: 10%;
    color: #fff;
    font-size: 12px;
    transform: rotate(-100deg);
    text-align: center;
  }

  &-item {
    position: absolute;
    top: 40%;
    left: 80%;
    display: flex;
    flex-direction: column-reverse;
    width: 2px;
    height: 40px;
    background: #cca26e;
    transform-origin: 50% 10%;

    >span {
      height: 20px;
      background: $ganglan;
      border-bottom-right-radius: 2px;
    }
  }

  @for $i from 1 through $count {
    &-item:nth-of-type(#{$i}) {
      animation: unfold#{$i} .2s ease-out forwards;

      >span {
        width: 12px;
        margin-left: -10px;
        border-left: 1px solid $ganglan;
      }
    }
  }

  @each $key, $value in $color-list {
    &-#{$key} > &-item > span {
      background: $value;
      border-color: $value;
    }
  }

  &-item:nth-of-type(7) {
    >span {
      margin-left: -5px;
    }
  }

  &-item:nth-of-type(8) {
    border-right: 0.1px solid #cca26e;

    >span {
      width: 12px;
      margin-left: 2px;
    }
  }

  &-fold {
    @for $i from 1 through $count {
      .zhui-switch-item:nth-of-type(#{$i}) {
        animation: fold#{$i} .2s ease-in forwards;
      }
    }
  }
}

@for $i from 1 through $count {
  @keyframes fold#{$i} {
    from {
      transform: rotate($i * 18deg);
    }

    to {
      width: 2px;
      transform: rotate($i * 1deg);
      overflow: hidden;
    }
  }

  @keyframes unfold#{$i} {
    from {
      width: 3px;
      overflow: hidden;
    }

    to {
      transform: rotate($i * 18deg);
    }
  }
}